import 'package:flutter/material.dart';
import 'package:hktk_app/model/yidun/ios_config_model.dart';
import 'package:hktk_app/model/yidun/ios_widget_model.dart';
import 'package:hktk_app/util/view_util.dart';

/// 一键登录的工具类
class YidunUtil {
  static late double screenWidth; // 屏幕宽度
  static late double screenHeight; // 屏幕高度
  static late double ratio; // 屏幕比例

  /// 根据设计稿实际宽度初始化
  /// baseHeight 设计稿宽度
  static init(BuildContext context, {double baseHeight = 350}) {
    Size size=MediaQuery.sizeOf(context);
    screenWidth =size.width;
    screenHeight = size.height;
    ratio = screenHeight / baseHeight;
  }

  /// 获取设计稿对应的高度
  static double getPxH(double size) {
    return YidunUtil.ratio * size;
  }
}

/// 获取iOS对应的自定义页面
IosConfigModel getIosConfig() {
  return IosConfigModel(
    backgroundColor: "#FFFFFF",
    authWindowPop: 0,
    faceOrientation: 0,
    bgImage: "yjdlBg.imageset",
    contentMode: 0,
    widgets: [
      IosWidgetModel(
        type: "UIButton",
        image: "iconBj",
        action: "loginBj",
        frame: FrameModel(
          mainScreenLeftDistance: 199,
          mainScreenTopDistance: YidunUtil.getPxH(1176),
          width: 84,
          height: 84,
        ),
      ),
      IosWidgetModel(
        type: "UIButton",
        image: "iconPg",
        action: "loginPg",
        frame: FrameModel(
          mainScreenRightDistance: 199,
          mainScreenTopDistance: YidunUtil.getPxH(1176),
          width: 84,
          height: 84,
        ),
      ),
      IosWidgetModel(
        type: "UIButton",
        image: "iconYkdl",
        action: "loginYkfh",
        frame: FrameModel(
          mainScreenLeftDistance: 48,
          mainScreenTopDistance: 20,
          width: 48,
          height: 48,
        ),
      ),
      IosWidgetModel(
        type: "UIButton",
        title: "HELLO，",
        titleColor: "#1E2023",
        titleFont: 48,
        textAlignment: 1,
        frame: FrameModel(
          mainScreenLeftDistance: 70,
          mainScreenTopDistance: YidunUtil.getPxH(152),
          width: 208,
          height: 67,
        ),
      ),
      IosWidgetModel(
        type: "UIButton",
        title: "欢迎来到中震网校",
        titleColor: "#1E2023",
        titleFont: 48,
        textAlignment: 0,
        frame: FrameModel(
          mainScreenLeftDistance: 70,
          mainScreenTopDistance: YidunUtil.getPxH(230),
          width: 400,
          height: 67,
        ),
      ),
    ],
    navBarHidden: true,
    logoHidden: true,
    numberColor: "#1E2023",
    numberFont: 48,
    numberOffsetTopY: YidunUtil.getPxH(582),
    numberOffsetX: 0,
    numberHeight: 68,
    brandColor: "#999A9C",
    brandFont: 26,
    brandOffsetTopY: YidunUtil.getPxH(666),
    logBtnOffsetTopY: YidunUtil.getPxH(782),
    logBtnRadius: 44,
    logBtnHeight: 88,
    logBtnOriginLeft: 0,
    logBtnOriginRight: 0,
    logBtnUsableBGColor: "#0A71FF",
    logBtnEnableImg: "logBtn",
    logBtnHighlightedImg: "logBtn",
    checkboxWH: 24,
    checkBoxAlignment: 0,
    checkBoxMargin: 14,
    appPrivacyOriginLeftMargin: 108,
    appPrivacyOriginRightMargin: 70,
    appPrivacyOriginBottomMargin: YidunUtil.getPxH(20),
    appPrivacyText: "我已阅读并同意《默认》以及“用户协议”和用户“隐私政策”",
    appFPrivacyText: "“用户协议”",
    appFPrivacyURL: "",
    appSPrivacyText: "“隐私政策”",
    appSPrivacyURL: "",
    privacyColor: "#1E2023",
    privacyFont: 24,
    protocolColor: "#0A71FF",
    showPrivacyDialog: 1,
  );
}
